package com.ldk.admin.ex;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

/**
 * 全局异常处理,但是处理不了404 400 500这些错误
 * @author xiangwl
 * 2016年12月29日
 * com.ycwl.bz.coopwin.web.controller.ex
 * GlobalExceptionHandler
 */
@Component
public class GlobalExceptionHandler implements HandlerExceptionResolver {
	
	private final Logger LOGGER = LoggerFactory.getLogger(GlobalExceptionHandler.class);

	@Override
	public ModelAndView resolveException(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {
		LOGGER.error("GlobalExceptionHandler::" + ex.getMessage());
		return new ModelAndView("error");
	}

}
